#include <algorithm>
#include <iostream>
#include <string>

using ll = long long;

auto &is = std::cin;
auto &os = std::cout;

const ll max_n{200+5};
std::string a,b;
ll dp[max_n][max_n];

int main(){
    while (is>>a>>b) {
        a=' '+a;
        b=' '+b;

        for(ll i{1};i<a.size();i++){
            for(ll j{1};j<b.size();j++){
                if(a[i]==b[j]){
                    dp[i][j]=dp[i-1][j-1]+1;
                }else{
                    dp[i][j]=std::max({dp[i][j-1],dp[i-1][j]});
                }
            }
        }
        os<<dp[a.size()-1][b.size()-1]<<'\n';
    }
}